<?php
	// +----------------------------------------------------------------------
	// | 行为模型
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------
	namespace app\model\store;

	use app\model\file\Image;
	use think\facade\Event;

	class Activity extends Common
	{


		public function cover()
		{
			return $this->belongsTo(Image::class, 'cover_id');
		}

		public function goods()
		{
			return $this->belongsToMany(Good::class, ActivityGood::class);
		}

		public function getIsEndAttr($value, $data)
		{
			return $data['end_time'] > time_format() ? 0 : 1;
		}
		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
		}
		//类型转换
		protected $type = [];

	}
